<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>系统用户</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
    <form  action="sysuser/${action eq "create" ?"save":"update"}" name="inputForm" id="inputForm" method="post" class="form-horizontal">
        <input name="id" id="id" value="${entity.id}" type="hidden" />
        <div class="form-group">
            <label class="col-sm-1 control-label">账号：</label>
            <div class="col-md-4">
                <input type="text" class="form-control" name="account" value="${entity.account}" placeholder="账号" readonly="readonly">
            </div>
            <label class="col-sm-1 control-label">密码：</label>
            <div class="col-md-4">
                <input type="password" class="form-control" name="password" value="" placeholder="密码">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label">部门：</label>
            <div class="col-md-4">
                <d:select clazz="selectpicker" list="${departments}" name="departmentId" selected="${entity.departmentId}" ></d:select>
            </div>
            <label class="col-sm-1 control-label">电话：</label>
            <div class="col-md-4">
                <input type="text" class="form-control" name="phone" value="${entity.phone}" placeholder="电话">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label">姓名：</label>
            <div class="col-md-4">
                <input type="text" class="form-control" name="name" value="${entity.name}" placeholder="姓名">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-1 control-label">状态：</label>
            <div class="col-md-4">
                <d:radio list="${userStatus}" name="status" selected="${entity.status}"></d:radio>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-1 col-sm-2">
                <button id="saveBtn" type="submit" class="btn btn-sm btn-primary"><i class="fa fa-floppy-o"></i> 提交</button>
                <button type="button" class="btn btn-sm link_close"><i class="fa fa-close"></i> 关闭</button>
            </div>
        </div>
    </form>
</div><!--/#main-container-->

<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script type="text/javascript">
    $(document).ready(function(e) {
        var options = {
            rules:{
                account:{required:true,maxlength : 40},
                password:{required:false,minlength : 6,maxlength : 20},
                departmentId:{required:true},
                phone:{required:false},
                name:{required:false,maxlength : 40},
                status:{required:true},
                roleIds:{required:true}
            },
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type:'post',
                    dataType:'json',
                    success:function(data){
                        if(data.success){
                            $('#searchBtn', parent.document).click();
                            closeIframe();
                        }else{
                            layer.alert(data.msg);
                        }
                    }
                });
            }
        };
        $("#inputForm").validate(options);
    });
</script>
<!-- script end -->
</body>
</html>
